charset="UTF-8"

Ext.onReady(function(){

	
	var hospitalRecord = Ext.data.Record.create([
				{name:'id'},  
              {name:'name'},  
              {name:'admin'},  
              {name:'setupdate',type : 'date', dateFormat : 'm-d-Y' },  
              {name:'introduction'}  
		]);

    var hospitalStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({  
                	url:"queryHospitalByPageAndNamePublic.action",  
                    method:"post"  
                }),  
        reader : new Ext.data.JsonReader({
        	totalProperty : 'totalProperty',
        	root : 'hospitalVOList'
        	 }, 
        	 hospitalRecord
        	 )
    });
    


    // Custom rendering Template
    var resultTpl = new Ext.XTemplate(
        '<tpl for="."><div class="search-item">',
            '<h3>{name}</h3><br>{setupdate:date("Y-m-d")}<br>{introduction}',
        '</div></tpl>'
    );
    
    var search = new Ext.form.ComboBox({
        store: hospitalStore,
        displayField:'name',
        typeAhead: false,
        loadingText: '查询中...',
        width: 770,
        pageSize:10,
        minChars:0,
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'search',
        itemSelector: 'div.search-item',
        onSelect: function(record){ // override default onSelect to do redirect
            window.location =
                String.format('queryTopDepartmentPublic.action?hospitalId={0}&size=10', record.data.id);
        }
    });
});